<?php
function start_session($expire = 0)
{
    if ($expire == 0) {
        $expire = ini_get('session.gc_maxlifetime');
    } else {
        ini_set('session.gc_maxlifetime', $expire);
     }

    if (empty($_COOKIE['PHPSESSID'])) {
        session_set_cookie_params($expire);
        session_start();
    } else {
        session_start();
        setcookie('PHPSESSID', session_id(), time() + $expire);
     }
}
start_session(3600*12);
include "inc/head.php";

if($_POST['AName'] != '' && $_POST['APwd'] != '')
{
	if(Admin::login($_POST))
	{
	  
     
 
		new ActionLog(array("LogType"=>"login_sucess","Action"=>"{$_POST[AName]}"));
		//alert("login sucess","location","index.php");
		exit('<script type="text/javascript">document.location.href="index.php";</script>');
	}
	else
	{
		new ActionLog(array("LogType"=>"login_err","Action"=>"{$_POST[AName]},{$_POST[APwd]}"));
		alert("用户名或密码错","location","login.php");
	}
}

if($_GET['action'] == 'logout')
{
	add_log($_SESSION['AName'].date("Y-m-d H:i:s").'退出系统','cms','','cms.wondershare.com','',$_SESSION['AName']);
	$_SESSION['AID'] = '';
	session_destroy();
}

?>

<script>if(location.href != top.location.href)top.location.href=location.href;</script>

<link rel="stylesheet" type="text/css" href="./bg/login/css.css">
<script type="text/javascript">
function checkLogin() {

	var n = document.f_login.AName.value;
	var p = document.f_login.APwd.value;

	if ( !n ) {
		alert("请输入用户名");
		document.f_login.name.focus();
		return false;
	}
	
	if ( !p ) {
		alert("请输入密码");
		document.f_login.password.focus();
		return false;
	}

	return true;
}
</script>
<div class="login">
	<div class="login_titile"><br /><p align="center" style="font-size:19px">CMS系统后台</p><font color="#FF0000"></font></div>
	<div class="login_main">
		<form name="f_login" method="post" onsubmit="return checkLogin();">
			<table width="100%" border="0">
				<tr>
					<td align="right">用户名:</td>
					<td><input name="AName" type="text" class="txt" tabindex="1" /></td>
					<td rowspan="2"><input name="tijiao" type="submit" class="btn" tabindex="3" value="" /></td>
				</tr>
				<tr>
					<td align="right">密　码:</td>
					<td><input name="APwd" type="password" class="txt"  tabindex="2" /></td>
				</tr>
			</table>
		</form>
	</div>
</div>

<?php
include 'inc/foot.php';

?>